from selenium.webdriver.common.by import By
from base.base_action import BaseAction


# 职级管理页面
class RankManagePage(BaseAction):

    # 职级管理按钮
    rank_manage_btn = By.XPATH, "//span[text()='职级管理']"

    # 新建按钮
    new_btn = By.XPATH, "//span[text()='新增职级']"

    # 职级名称输入框
    rank_name_input = By.XPATH, "//input[@placeholder='请输入职级名称']"

    # 确定按钮
    determine_btn = By.XPATH, "//button[@class='el-button el-button--primary el-button--mini']/span"

    # 上移/下移
    move_up_btn = "document.getElementsByClassName('operate-style')[5].click();"
    move_down_btn = "document.getElementsByClassName('operate-style')[6].click();"

    # 弹窗的确定按钮
    determine2_btn = By.XPATH, "/html/body/div[2]/div/div[3]/button[2]/span"

    # 点击职级管理
    def click_rank_manage_btn(self):
        return self.click(self.rank_manage_btn)

    # 点击新增按钮
    def click_new_btn(self):
        return self.click(self.new_btn)

    # 输入职级名称
    def input_rank_name(self, content):
        return self.input(self.rank_name_input, content)

    # 点击确定按钮
    def click_determine_btn(self):
        return self.click(self.determine_btn)

    # 清空输入框
    def clear_rank_name_input(self):
        return self.clear(self.rank_name_input)

    # 点击上移
    def click_move_up_btn(self):
        return self.execute_js(self.move_up_btn)

    # 点击下移
    def click_move_down_btn(self):
        return self.execute_js(self.move_down_btn)


